<template>
  <div class="login">
    <h1>用户登录界面</h1>
    用户名：<input type="text" v-model="username">
    <br>
    密码：<input type="password" v-model="password">
    <br>
    <button @click="login">登录</button>
  </div>
</template>

<script>
export default {
  name: 'LoginView',
  data () {
    return {
      username: '',
      password: ''
    }
  },
  methods: {
    login () {
      if (this.username === 'zs' && this.password === '123456') {
        window.localStorage.setItem('userToken', { username:this.username, password:this.password })
        console.log('登陆成功')
        this.$router.push({
          path: '/'
        })
      } else {
        alert('用户名或者密码错误！！！')
      }
    }
  }
}
</script>

<style scoped>
.login{
  width: 300px;
  text-align: center;
  margin: 0 auto;
}
h1{
  color: #dd4646
}
button{
  border: none;
  background-color: #67d370;
  width: 100px;
  height: 50px;
  line-height: 50px;
  text-align: center;
  border-radius: 10px;
  font-size: 25px;
  color: #ffffff;
  font-weight: 600;
  margin-top: 20px;
  cursor: pointer;
}
</style>
